package ws.db;

import java.util.ArrayList;
import java.util.Iterator;

public class ColumnAttrPair {
	
	public String column;
	public String attr;
	
	
	
	/**
	 * 
	 * Construct Function.
	 * @param:
	 * 		m_column - the table column name.
	 * 		m_attr - the class attribute name.
	 * 
	 * */
	public ColumnAttrPair(String m_column,String m_attr){
		column = m_column;
		attr = m_attr;
	}
	
	
	/**
	 * You must allocat the columns memory before call the function.
	 * @param:
	 * 		arrayList - the column and attribution pairs.
	 * 		columns - the columns array storage the columns gets from the arrayList.
	 * @return:
	 * 		void.
	 * 
	 */
	public static void ChangArrayListToStringArray(ArrayList<ColumnAttrPair> arrayList,String[] columns){
		int i=0;
		Iterator its = arrayList.iterator();
		while(its.hasNext()){
			ColumnAttrPair each = (ColumnAttrPair)its.next();
			columns[i++] = each.column;
		}
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object columnName) {
		// TODO Auto-generated method stub
		
		if(columnName instanceof ColumnAttrPair) {
			if( ((ColumnAttrPair)columnName).column.equals(this.column)){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "column="+column+"\t attr="+attr;
	}
	
	
	
	
}
